/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package rule.occurance;

import rule.Rule;

/**
 *
 * @author Daniel Gribel
 */
public abstract class OccuranceRule extends Rule {
    private int desiredScore;
    private int numDigits;

    public OccuranceRule(int numDigits, int desiredScore) {
        this.numDigits = numDigits;
        this.desiredScore = desiredScore;
    }

    public int getDesiredScore() {
        return desiredScore;
    }

    public void setDesiredScore(int desiredScore) {
        this.desiredScore = desiredScore;
    }

    public int getNumDigits() {
        return numDigits;
    }

    public void setNumDigits(int numDigits) {
        this.numDigits = numDigits;
    }

    @Override
    public void checkConditions(String dataEntry) {
        int counter = 0;
        for (char a : dataEntry.toCharArray()) {
            if (checkType(a))
                counter++;
        }
        if(counter >= getNumDigits())
            setScore(getDesiredScore());
    }

    public abstract boolean checkType(char character);
    
    @Override
    public abstract String outputMessage();
    
}
